﻿using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lails
{
    public abstract class QuartzTask : IJob
    {
        public IJobExecutionContext Context { get; private set; }

        public Task Execute(IJobExecutionContext context)
        {
            Context = context;

            string key = "context";
            object cx = null;
            if (context.JobDetail.JobDataMap.Contains(key))
            {
                cx = context.JobDetail.JobDataMap[key];
            }
            return ExecuteTask(cx);
        }

        public abstract Task ExecuteTask(object context);
    }
}
